home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / UVE138.ZIP / EXAMPLES.ZIP / GLENZ2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-08-30  |  1.4 KB  |  78 lines

  1. {$A+,B-,D+,E+,F-,G+,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+}
  2. {$M 16384,0,655360}
  3.  
  4. {
  5. GLENZ2.PAS
  6. Demonstrates     - sprite color mapping
  7.         - sprite transparency
  8.         - higher level of sprite encapsulation
  9. }
  10.  
  11. uses    crt,uve32;
  12.  
  13. const    maxspheres=200;
  14.  
  15. type    spheretype=record
  16.         x,y,
  17.         forcex,forcey:longint;
  18.     end;
  19.  
  20. var    sphere:array[1..maxspheres] of spheretype;
  21.  
  22. procedure init;
  23. var    pal:palette;
  24.     i:integer;
  25. begin
  26.     ia_inituve;
  27.     ia_loadspr('sphere.uvl',1);
  28.     ia_chainsprite(1,spritesloaded,1);
  29.     for i:=0 to 63 do with pal[i] do begin
  30.         red:=i;
  31.         green:=i;
  32.         blue:=i;
  33.     end;
  34.     ia_makeglenzmap(pal,5,5,5,maparray[1]);
  35.     ia_powerup;
  36.     ia_setpalette(pal);
  37.     ia_setcycletime(40);
  38.     for i:=1 to maxspheres do with sphere[i] do begin
  39.         x:=longint(160)*256;
  40.         y:=longint(200)*256;
  41.         forcex:=(longint(random(2560))-1280);
  42.         forcey:=-(longint(random(2560)));
  43.         spr[i].n:=1+random(30);
  44.         spr[i].transparent:=true;
  45.         spr[i].map:=1;
  46.     end;
  47. end;
  48.  
  49. procedure deinit;
  50. begin
  51.     ia_shutdown;
  52.     halt;
  53. end;
  54.  
  55.  
  56. procedure movespheres;
  57. var    i:integer;
  58. begin
  59.     for i:=1 to maxspheres do with sphere[i] do begin
  60.         inc(x,forcex);
  61.         inc(y,forcey);
  62.         if (y>200*256) and (forcey>0) then
  63.             forcey:=-forcey
  64.             else inc(forcey,64);
  65.         if (x<0) and (forcex<0) then forcex:=-forcex;
  66.         if (x>320*256) and (forcex>0) then forcex:=-forcex;
  67.         ia_center(i,x div 256,y div 256,2);
  68.     end;
  69. end;
  70.  
  71. begin
  72.     init;
  73.     repeat
  74.         movespheres;
  75.         ia_doframe;
  76.     until keypressed;
  77.     deinit;
  78. end.